var logisticsBusiness = {
    logisticsData: {},
    logisticsBusinessData: {logisticsId: '', monthOutAmount: 0, monthInAmount: 0, statisticsTime: ''},
    //添加物流业务量信息
    addLogisticsBusiness: function () {
        logisticsBusiness.logisticsBusinessData.logisticsId = logisticsBusiness.logisticsData.id;
        logisticsBusiness.logisticsBusinessData.monthOutAmount = $('#month-out-amount').val().trim();//月发出量
        logisticsBusiness.logisticsBusinessData.monthInAmount = $('#month-in-amount').val().trim();//月发入量
        logisticsBusiness.logisticsBusinessData.statisticsTime = $('#statistics_time').val().trim();//统计时间
        console.log(logisticsBusiness.logisticsBusinessData);
        $.ajax({
            url: '/ebb/logistics/business',
            type: 'post',
            data: JSON.stringify(logisticsBusiness.logisticsBusinessData),
            contentType: "application/json",
            success: function (result) {
                window.location.href = 'logisticsManager.html';//返回物流管信息理列表
            }
        });
    },
    //加载物流信息
    loadLogistics: function (id) {
        $.ajax({
            url: '/ebb/logistics/' + id,
            type: 'get',
            success: function (result) {
                if (result != null) {
                    logisticsBusiness.logisticsData = result;
                    $('#branch-name').text(result.branchName);//网点名称
                }
            }
        });
    }

};
$(document).ready(function () {
    //时间选择器
    timeUtil.select('#statistics_time');
    //取消
    $('#cancel').click(function () {
        window.location.href = 'logisticsManager.html';
    });
    var logisticsId = GetQueryString('logisticsId');
    if (logisticsId != null && logisticsId != '') {
        logisticsBusiness.loadLogistics(logisticsId);//加载物流信息
    }

    $("#logistics-business-form").validate(
        {
            debug: true,//只验证不提交表单
            submitHandler: function (form) {
                logisticsBusiness.addLogisticsBusiness();//表单验证通过后执行
            }
        }
    );
});

